Guys I'm so confused[update]

Kinja'd!!! "Cherry_man1" (Cherry_man1)
11/18/2014 at 14:27 • Filed to: Programming

Kinja'd!!!0 Kinja'd!!! 15

this is the !!!error: Indecipherable SUB-paragraph formatting!!! i'm working on right now. I'm so lost trying to count the bastards.

Help. Take this GT350 for help.

[update]: NOW SHUFFEL THE THIGNS!

Kinja'd!!!

DISCUSSION (15)


Kinja'd!!! For Sweden > Cherry_man1
11/18/2014 at 14:30

Kinja'd!!!2

!!! UNKNOWN CONTENT TYPE !!!


Kinja'd!!! Mercedes Streeter > Cherry_man1
11/18/2014 at 14:36

Kinja'd!!!1

I'm in an introductory Computer Science class myself and I have no clue what the heck that lab is about. Now I'm scared...

!!! UNKNOWN CONTENT TYPE !!!


Kinja'd!!! CalzoneGolem > Cherry_man1
11/18/2014 at 14:41

Kinja'd!!!0

I've got the skills to figure this out but I don't have the will or time.


Kinja'd!!! Tohru > Cherry_man1
11/18/2014 at 14:42

Kinja'd!!!7

Kinja'd!!!

I've been out of school too long.


Kinja'd!!! Group B Enthusiast - Captain of the supercharged barge > Cherry_man1
11/18/2014 at 14:43

Kinja'd!!!0

I can no essplain...


Kinja'd!!! Mattbob > Cherry_man1
11/18/2014 at 14:43

Kinja'd!!!0

just make and array of size 10 "counts(10)" then iterate through and increment the corresponding spot in the array for each number you see.

x = next nubmer in the given numbers

counts(x)++

move to next number

what language is this?

*edit* I've never used python, so my pseudocode is probably shit, but I hope you get the idea.


Kinja'd!!! Cherry_man1 > Mattbob
11/18/2014 at 14:44

Kinja'd!!!0

Python


Kinja'd!!! Alfalfa > Cherry_man1
11/18/2014 at 14:44

Kinja'd!!!2

There was a time when I knew how to do this. Then I finished my AP computer science course, and decided that I never wanted to code again. It's been a happy 8 years.


Kinja'd!!! Mattbob > Cherry_man1
11/18/2014 at 14:47

Kinja'd!!!1

never used it, but I have a raspberry pi at home that is telling me I need to learn.


Kinja'd!!! Mattbob > Cherry_man1
11/18/2014 at 14:48

Kinja'd!!!0

do you get what I am saying though, as far as how to do it? or is it a more specific thing that you aren't getting?


Kinja'd!!! BoulderZ > Cherry_man1
11/18/2014 at 14:49

Kinja'd!!!0

Set up your counts list, then go in a loop (yeah, I know, inefficient, but ends/means, right?) of 1000 iterations, in each iteration make the call random.randint(0,9) and truncate it (so you get perfect 0,1,...,9. Use the number as the key in to your counts, using a ++ to increment the count up one from what it was.


Kinja'd!!! Cherry_man1 > Mattbob
11/18/2014 at 14:49

Kinja'd!!!0

I got it now but the way you tried to explain was way off


Kinja'd!!! Mattbob > Cherry_man1
11/18/2014 at 14:53

Kinja'd!!!0

Good to know. The method, or the syntax? I should have probably not skimmed it, but I am at work.


Kinja'd!!! BoulderZ > Cherry_man1
11/18/2014 at 15:25

Kinja'd!!!0

Here, test run in PyCharm CE, 2.7.whatever

import random

counts=[0,0,0,0,0,0,0,0,0,0]

for i in range(1000):

var = random.randint(0,9)

counts[var] += 1

print counts


Kinja'd!!! BoulderZ > Cherry_man1
11/18/2014 at 15:59

Kinja'd!!!0

Here it is with a shuffle-not-using-shuffle (list.pop is the trick):

import random

def CM1Shuffle(arg1):

RetVal = [0] * len(arg1)

for i in range(len(arg1)):

iPull = random.randint(0,len(arg1)-1)

RetVal[i] = arg1.pop(iPull)

return RetVal

counts=[0,0,0,0,0,0,0,0,0,0]

for i in range(1000):

var = random.randint(0,9)

counts[var] += 1

print 'Counts'

print counts

sCounts = CM1Shuffle(counts)

print 'sCounts'

print sCounts